package com.leyou.common.pojo;

import java.util.Random;

public class NumberUtils {

    /**
     * 生成随机数的工具类
     * @Author Allen-fanxin
     * @Date 2020/9/27 18:00
     * @params [len]
     * @Since version-1.0
     */
    public static String generateCode(int len){
        len = Math.min(len, 8);
        int min = Double.valueOf(Math.pow(10, len - 1)).intValue();
        int num = new Random().nextInt(
                Double.valueOf(Math.pow(10, len + 1)).intValue() - 1) + min;
        return String.valueOf(num).substring(0,len);
    }

}
